package com.example.shujujiegousuanfa.链表;

public class LinkListIterator<T> {
    private Node<T> current;
    private LinkList<T> list;

    public LinkListIterator(LinkList<T> list) {
        this.list = list;
        this.current = list.first;
    }


    public Boolean empty() {
        return this.current == null;
    }

    public Boolean nextEmpty() {
        return this.current == null || this.current.next == null;
    }

    public T first() {
        if (list.first.next != null) {
            this.current = this.list.first;
            return this.current.data;
        }

        this.current = null;
        return null;
    }

    public T next() {
        if (this.current != null && this.current.next != null) {
            this.current = this.current.next;
            return this.current.data;
        }
        this.current = null;
        return null;
    }

}
